import defaultSettings from '@/settings'
import Layout from '@/layout'
const { showSettings, fixedHeader, sidebarLogo } = defaultSettings

const state = {
  showSettings: showSettings,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo,
  teacherRoutes: [
    {
      path: '/',
      component: Layout,
      redirect: '/dashboard',
      children: [
        {
          path: 'dashboard',
          name: 'Dashboard',
          component: () => import('@/views/dashboard/index'),
          meta: { title: '主页', icon: 'dashboard' }
        },
        {
          path: 'classdetail',
          name: 'ClassDetail',
          hidden: true,
          component: () => import('@/views/class_detail/index'),
          meta: { title: '班级详情', icon: 'dashboard' }
        }
      ]
    },
    {
      path: '/example',
      component: Layout,
      redirect: '/stats/index',
      name: 'Example',
      meta: { title: '班级课程', icon: 'el-icon-s-help' },
      children: [
        {
          path: 'stats',
          name: 'Table',
          component: () => import('@/views/stats/index'),
          meta: { title: '统计成绩', icon: 'table' }
        },
        {
          path: 'timetable',
          name: 'Tree',
          component: () => import('@/views/timetable/index'),
          meta: { title: '安排课表', icon: 'tree' }
        }
      ]
    }
  ],
  studentRoutes: [
    {
      path: '/',
      component: Layout,
      redirect: '/dashboard',
      children: [
        {
          path: 'dashboard',
          name: 'Dashboard',
          component: () => import('@/views/students/index'),
          meta: { title: '主页', icon: 'dashboard' }
        }
      ]
    }
  ]
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

